
namespace Patterns4Net.Core.Patterns
{
    using Mono.Cecil;
    using Attributes.DesignPatterns;

    [Immutable]
    public class Immutable : PatternBase
    {
        public Immutable(TypeDefinition targetType, bool deep)
        {
            this.TargetType = targetType;
            this.Deep = deep;
        }

        public TypeDefinition TargetType { get; private set; }

        public bool Deep { get; private set; }
        
        public override bool Equals(object obj)
        {            
            if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }

            var other = (Immutable)obj;
            return other.Deep == this.Deep;            
        }

        public override int GetHashCode()
        {
            return this.Deep.GetHashCode();
        }
    }
}
